//
//  NormalTalk.m
//  Conference Track Management
//
//  Created by Jiang on 2018/10/22.
//  Copyright © 2018 jiang. All rights reserved.
//

#import "NormalTalk.h"

@implementation NormalTalk
- (instancetype)initWitContent:(NSString *)content{
    return [self initWitContent:content tag:0];
}
- (instancetype)initWitContent:(NSString *)content tag:(NSUInteger)tag{
    self = [super init];
    self.content = content;
    self.duration = [self calculatorDuration];
    self.tag = tag;
    return self;
}
- (int)calculatorDuration{
    NSArray <NSString *> * elements = [self.content componentsSeparatedByString:@" "];
    if ([elements.lastObject hasSuffix:@"min"]) {
        return [elements.lastObject substringWithRange:NSMakeRange(0, elements.lastObject.length - 3)].intValue;
    }else if ([elements.lastObject isEqualToString:@"lightning"]) {
        return 5;
    }
    return 0;
}
- (BOOL)verifyContent{
    NSArray <NSString *> * elements = [self.content componentsSeparatedByString:@" "];
    if (elements.count == 0) {
        return NO;
    }
    int passed = 0;
    passed |= [elements.lastObject hasSuffix:@"min"]
               && [elements.lastObject substringWithRange:NSMakeRange(0, 3)].intValue > 0;
    passed |= [elements.lastObject isEqualToString:@"lightning"];
    return passed;
}
- (NSString *)description{
    return self.content;
}
@end
